home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************
- *
- * $Source: /unixb/home/unixlib/source/unixlib37/src/signal/c/RCS/signal,v $
- * $Date: 1996/10/30 22:04:51 $
- * $Revision: 1.1 $
- * $State: Rel $
- * $Author: unixlib $
- *
- * $Log: signal,v $
- * Revision 1.1 1996/10/30 22:04:51 unixlib
- * Initial revision
- *
- ***************************************************************************/
-
- static const char rcs_id[] = "$Id: signal,v 1.1 1996/10/30 22:04:51 unixlib Rel $";
-
- /* Written by Nick Burrett, 27 August 1996. */
-
- #include <errno.h>
- #include <signal.h>
-
-
- /* Set the handler for the signal 'sig' to handler, returning
- the old handler, or SIG_ERR on error. */
- sighandler_t
- signal (int sig, sighandler_t handler)
- {
- struct sigaction act, oact;
-
- if (handler == SIG_ERR
- || sig <= 0 || sig >= NSIG
- || sig == SIGKILL || sig == SIGSTOP)
- {
- errno = EINVAL;
- return SIG_ERR;
- }
-
- act.sa_handler = handler;
- if (sigemptyset (&act.sa_mask) < 0)
- return SIG_ERR;
- act.sa_flags = 0; /* sigismember (&_sigintr, sig) ? 0 : SA_RESTART; */
- if (sigaction (sig, &act, &oact) < 0)
- return SIG_ERR;
-
- return oact.sa_handler;
- }
-